package com.exam.scjp5.objectives.section_1;

public class ExampleInheritence2
{
    public static void main(String[] args)
    {
        System.out.println("EIClassA : ");
        EIClassA a = new EIClassA();
        System.out.println("EIClassB : ");
        EIClassB b = new EIClassB();
        
        System.out.println("EIClassA.i : " + a.i);
        System.out.println("EIClassB.i : " + b.i);
        
        a = b;
        System.out.println("EIClassA.i (a = b): " + a.i);
        System.out.println("EIClassA.i (with getter): " + a.getI());
    }

}


class EIClassA
{
    public int i = 10;

    EIClassA()
    {
        System.out.println("here 'i' is : " + i);
        System.out.println("here 'i' is (with getter) : " + this.getI());
    }
    
    public int getI()
    {
        return i;
    }
    
    
}

class EIClassB extends EIClassA
{
    public int i = 20;
    
    static
    {
        new EIClassB();
    }
    
    public int getI()
    {
        return i;
    }
    
}